#include<iostream>
#include <direct.h>
#include <windows.h>
#include <CXX/Objects.hxx>

#include "Workbench.h"
#include "WorkbenchPy.h"

struct MyModuleWorkbench : public Workbench  
{
	MyModuleWorkbench(){
		MenuText = "MyModule";
		ToolTip = "MyModule workbench";
		Icon = "MyModule icon";
	}
	virtual void Initialize(){}
	virtual std::string GetClassName() { return "MyModuleGui::Workbench"; }
};

int main(int args,char* argc[])
{
	wchar_t buf[256];
	_wgetcwd(buf,256);
	wsprintfW(buf, L"%s/../../3rdparty/Python38", buf);
	Py_SetPythonHome(buf);
	Py_Initialize();

	MyModuleWorkbench* workbench = new MyModuleWorkbench;
	WorkbenchPy* workbenchpy = new WorkbenchPy(workbench);
	Py::Object object(workbenchpy,true);
	/*Py::Callable creation(object);
	object = creation.apply();*/
	if (object.hasAttr("MenuText"))
	{
		Py::String name = object.getAttr("MenuText");
		std::string item = name.as_std_string("ascii");
		std::cout << item;
	}
	Py::Callable func = object.getAttr("GetClassName");
	Py::String name = func.apply();
	std::string item = name.as_std_string("ascii");
	std::cout << item;
	func = object.getAttr("Initialize");
	func.apply();

	Py::Object classobj = object.getAttr(std::string("__class__"));
	name = classobj.getAttr("__name__");
	item = name.as_std_string("ascii");
	std::cout << workbenchpy->getWorkbenchPtr()->GetClassNameA();

	//int ret = PyObject_SetAttrString(object.ptr(), "Empty", new PyObject);
	object.setAttr("Empty", Py::String("kity"));
	name = object.getAttr("Empty");
	item = name.as_std_string("ascii");
	object.setAttr("libs", Py::String("libs"));
	name = object.getAttr("libs");
	item = name.as_std_string("ascii");
	std::cout << workbenchpy->getWorkbenchPtr()->GetClassNameA();
	return 0;
}